﻿using DDD.Application;
using DotNetCore.CAP;
using GoodsModule.IntegrationEvents;
using MediatR;
using OrderModule.Application.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderModule.Application.IntegrationEventsHandler
{
    public class GoodsDeductStockSuccessIntegrationEventHanler(IMediator mediator)
        : IIntegrationEventHandler
    {
        [CapSubscribe(nameof(GoodsDeductStockSuccessIntegrationEvent))]
        public Task Handle(GoodsDeductStockSuccessIntegrationEvent @event, CancellationToken cancellationToken = default)
        {
            return mediator.Send(new OrderStatusPendingPayCommand(@event.OrderId));
        }
    }
}
